#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>

void signal_handler(int sig, siginfo_t* info, void* ucontext)
{
    printf("handler : sig = %d\n",            sig);
    printf("handler : info->si_signo = %d\n", info->si_signo);
    printf("handler : info->si_code = %d\n",  info->si_code);
    printf("handler : info->si_pid = %d\n",   info->si_pid);
    printf("handler : info->si_value = %d\n", info->si_value.sival_int);
}

int main(void)
{
    char buf[32] = {0};
    struct sigaction act = {0};
    
    act.sa_sigaction = signal_handler;
    act.sa_flags = SA_RESTART | SA_SIGINFO;
    
    sigaddset(&act.sa_mask, 40);
    
    sigaction(40, &act, NULL);
    
    while (1) {
        pause();
    }
    
    return 0;
}

